/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.agi.myhome.util;

import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Named;

/**
 *
 * @author Renato
 */
@Named(value = "facesMsg")
@RequestScoped
public class FacesMsg {
    private void addMsg(String title, String msg, FacesMessage.Severity severity){
        FacesContext fc;
        FacesMessage fm;
        fc=FacesContext.getCurrentInstance();  
        fm=new FacesMessage(severity,title, msg);
        fc.addMessage(null, fm);        
    }
    public void addInfo(String title, String info){
        this.addMsg(title, info,FacesMessage.SEVERITY_INFO);       
    }  
      
    public void addWarn(String title, String info) { 
        this.addMsg(title, info,FacesMessage.SEVERITY_WARN);        
    }  
      
    public void addError(String title, String info) { 
            this.addMsg(title, info,FacesMessage.SEVERITY_ERROR);
    }  

    public void addFatal(String title, String info) { 
        this.addMsg(title, info,FacesMessage.SEVERITY_FATAL);            
    }  
   
}
